package XO;

//import com.sun.java.util.jar.pack.Attribute;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by IntelliJ IDEA.
 * User: eagle
 * Date: 25.08.11
 * Time: 15:52
 * To change this template use File | Settings | File Templates.
 */
public class XOHostDialog extends JDialog {
//public class XOHostDialog extends JOptionPane {

	JTextField fieldSize;
	JTextField chainLength;
	JButton okButton;
	JButton cancelButton;

//	XOHostDialog(){
//		super();
//		initComponents();
//	}

	XOHostDialog(Frame owner){
		super(owner);
		initComponents();
	}

	private void initComponents(){
		this.setModal(true);
		this.setTitle("Field parameters");
		this.setSize(200,120);
		this.setAlwaysOnTop(true);
		this.setResizable(false);
		this.setLocationRelativeTo(this.getOwner());
        this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

		fieldSize = new JTextField(3);
		fieldSize.setHorizontalAlignment(SwingConstants.CENTER);
		chainLength = new JTextField(3);
		chainLength.setHorizontalAlignment(SwingConstants.CENTER);
		okButton = new JButton("Ok");
		cancelButton = new JButton("Cancel");

		this.getContentPane().setLayout(new FlowLayout(SwingConstants.VERTICAL));

		//Panels
		JPanel pTextFields = new JPanel(new GridLayout(2,2,3,3));
		pTextFields.add(new JLabel("Field Size", SwingConstants.RIGHT));
		pTextFields.add(fieldSize);
		pTextFields.add(new JLabel("Chain Length", SwingConstants.RIGHT));
		pTextFields.add(chainLength);

		JPanel pButtons = new JPanel(new GridLayout(1,2,3,3));
		pButtons.add(okButton);
		pButtons.add(cancelButton);

		this.getContentPane().add(pTextFields);
		this.getContentPane().add(pButtons);
		
		this.getContentPane().validate();
	}

	public void actionPerformed(ActionEvent ae)
	{
		
	}

	public int getFieldSize()
	{
		return Integer.parseInt(fieldSize.getText());
	}
	public int getChainLength()
	{
		return Integer.parseInt(chainLength.getText());
	}
}